﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using Server.Models;
using Server.Share;

namespace Server.Controllers.Manage
{
    [RoutePrefix("51API/Company")]
    public class CompanyController : ApiController
    {
        private MShare comm = new MShare();
        #region 公司管理
        /// <summary>
        /// 添加公司
        /// </summary>
        /// <param name="company"></param>
        /// <returns></returns>
        [Route("CompanyAdd")]
        public IHttpActionResult PostCompanyAdd(ManagerCompany company, string Token)
        {
            try
            {
                comm.CheckInfo(Token);
                comm.CheckAuth(comm.manager.id, "Company001");
                comm.companyCtrl.CompanyAdd(company);
                RetModel ret = new RetModel
                {
                    Data = null,
                    ErrCode = "",
                    ErrInfo = "",
                    Success = true
                };
                return Ok(ret);
            }
            catch (Exception ex)
            {
                return Ok(new RetModel { Success = false, ErrCode = "Company001", ErrInfo = ex.Message, Data = null });
            }
        }
        /// <summary>
        /// 修改公司
        /// </summary>
        /// <param name="company"></param>
        /// <returns></returns>
        [Route("CompanyEdit")]
        public IHttpActionResult PostCompanyEdit(ManagerCompany company, string Token)
        {
            try
            {
                comm.CheckInfo(Token);
                comm.CheckAuth(comm.manager.id, "Company002");
                comm.companyCtrl.CompanyEdit(company);
                RetModel ret = new RetModel
                {
                    Data = null,
                    ErrCode = "",
                    ErrInfo = "",
                    Success = true
                };
                return Ok(ret);
            }
            catch (Exception ex)
            {
                return Ok(new RetModel { Success = false, ErrCode = "Company002", ErrInfo = ex.Message, Data = null });
            }
        }
        /// <summary>
        /// 删除公司
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [Route("CompanyDel")]
        public IHttpActionResult PostCompanyDel(int id, string Token)
        {
            try
            {
                comm.CheckInfo(Token);
                comm.CheckAuth(comm.manager.id, "Company003");
                comm.companyCtrl.CompanyDel(id);
                RetModel ret = new RetModel
                {
                    Data = null,
                    ErrCode = "",
                    ErrInfo = "",
                    Success = true
                };
                return Ok(ret);
            }
            catch (Exception ex)
            {
                return Ok(new RetModel { Success = false, ErrCode = "Company003", ErrInfo = ex.Message, Data = null });
            }
        }
        /// <summary>
        /// 公司列表
        /// </summary>
        /// <returns></returns>
        [Route("GetCompanyList")]
        public IHttpActionResult PostGetCompanyList(string Token)
        {
            try
            {
                comm.CheckInfo(Token);
                comm.CheckAuth(comm.manager.id, "");
                ManagerCompany[] company = comm.companyCtrl.GetCompanyList();
                RetModel ret = new RetModel
                {
                    Data = company,
                    ErrCode = "",
                    ErrInfo = "",
                    Success = true
                };
                return Ok(ret);
            }
            catch (Exception ex)
            {
                return Ok(new RetModel { Success = false, ErrCode = "Company004", ErrInfo = ex.Message, Data = null });
            }
        }
        /// <summary>
        /// 通过name模糊查询公司
        /// </summary>
        /// <returns></returns>
        [Route("GetCompanyByName")]
        public IHttpActionResult PostGetCompanyByName(string name, string Token)
        {
            try
            {
                comm.CheckInfo(Token);
                comm.CheckAuth(comm.manager.id, "");
                ManagerCompany company = comm.companyCtrl.GetCompanyByName(name);
                RetModel ret = new RetModel
                {
                    Data = company,
                    ErrCode = "",
                    ErrInfo = "",
                    Success = true
                };
                return Ok(ret);
            }
            catch (Exception ex)
            {
                return Ok(new RetModel { Success = false, ErrCode = "Company005", ErrInfo = ex.Message, Data = null });
            }
        }
        #endregion
        #region 地区
        /// <summary>
        /// 添加省
        /// </summary>
        /// <param name="Token"></param>
        /// <returns></returns>
        [Route("ProvinceAdd")]
        public IHttpActionResult PostProvinceAdd(AreaProvinceModel Province, string Token)
        {
            try
            {
                comm.CheckInfo(Token);
                comm.CheckAuth(comm.manager.id, "Province001");
                comm.companyCtrl.ProvinceAdd(Province);
                RetModel ret = new RetModel
                {
                    Data = null,
                    ErrCode = "",
                    ErrInfo = "",
                    Success = true
                };
                return Ok(ret);
            }
            catch (Exception ex)
            {
                return Ok(new RetModel { Success = false, ErrCode = "Company011", ErrInfo = ex.Message, Data = null });
            }
        }
        /// <summary>
        /// 修改省
        /// </summary>
        /// <param name="Token"></param>
        /// <returns></returns>
        [Route("ProvinceEdit")]
        public IHttpActionResult PostProvinceEdit(AreaProvinceModel Province, string Token)
        {
            try
            {
                comm.CheckInfo(Token);
                comm.CheckAuth(comm.manager.id, "Province002");
                comm.companyCtrl.ProvinceEdit(Province);
                RetModel ret = new RetModel
                {
                    Data = null,
                    ErrCode = "",
                    ErrInfo = "",
                    Success = true
                };
                return Ok(ret);
            }
            catch (Exception ex)
            {
                return Ok(new RetModel { Success = false, ErrCode = "Company011", ErrInfo = ex.Message, Data = null });
            }
        }
        /// <summary>
        /// 删除省
        /// </summary>
        /// <param name="Token"></param>
        /// <returns></returns>
        [Route("ProvinceDel")]
        public IHttpActionResult PostProvinceDel(int id, string Token)
        {
            try
            {
                comm.CheckInfo(Token);
                comm.CheckAuth(comm.manager.id, "Province003");
                comm.companyCtrl.ProvinceDel(id);
                RetModel ret = new RetModel
                {
                    Data = null,
                    ErrCode = "",
                    ErrInfo = "",
                    Success = true
                };
                return Ok(ret);
            }
            catch (Exception ex)
            {
                return Ok(new RetModel { Success = false, ErrCode = "Company011", ErrInfo = ex.Message, Data = null });
            }
        }
        [Route("GetProvinceList")]
        public IHttpActionResult PostGetProvinceList(string Token)
        {
            try
            {
                comm.CheckInfo(Token);
                comm.CheckAuth(comm.manager.id, "");
                var area = comm.companyCtrl.GetProvinceList();
                RetModel ret = new RetModel
                {
                    Data = area,
                    ErrCode = "",
                    ErrInfo = "",
                    Success = true
                };
                return Ok(ret);
            }
            catch (Exception ex)
            {
                return Ok(new RetModel { Success = false, ErrCode = "Company011", ErrInfo = ex.Message, Data = null });
            }
        }
        /// <summary>
        /// 添加市
        /// </summary>
        /// <param name="City"></param>
        /// <param name="Token"></param>
        /// <returns></returns>
        [Route("CityAdd")]
        public IHttpActionResult PostCityAdd(AreaCityModel City, string Token)
        {
            try
            {
                comm.CheckInfo(Token);
                comm.CheckAuth(comm.manager.id, "City001");
                comm.companyCtrl.CityAdd(City);
                RetModel ret = new RetModel
                {
                    Data = null,
                    ErrCode = "",
                    ErrInfo = "",
                    Success = true
                };
                return Ok(ret);
            }
            catch (Exception ex)
            {
                return Ok(new RetModel { Success = false, ErrCode = "Company011", ErrInfo = ex.Message, Data = null });
            }
        }
        /// <summary>
        /// 修改市
        /// </summary>
        /// <param name="City"></param>
        /// <param name="Token"></param>
        /// <returns></returns>
        [Route("CityEdit")]
        public IHttpActionResult PostCityEdit(AreaCityModel City, string Token)
        {
            try
            {
                comm.CheckInfo(Token);
                comm.CheckAuth(comm.manager.id, "City002");
                comm.companyCtrl.CityEdit(City);
                RetModel ret = new RetModel
                {
                    Data = null,
                    ErrCode = "",
                    ErrInfo = "",
                    Success = true
                };
                return Ok(ret);
            }
            catch (Exception ex)
            {
                return Ok(new RetModel { Success = false, ErrCode = "Company011", ErrInfo = ex.Message, Data = null });
            }
        }
        /// <summary>
        /// 删除市
        /// </summary>
        /// <param name="City"></param>
        /// <param name="Token"></param>
        /// <returns></returns>
        [Route("CityDel")]
        public IHttpActionResult PostCityDel(int id, string Token)
        {
            try
            {
                comm.CheckInfo(Token);
                comm.CheckAuth(comm.manager.id, "City003");
                comm.companyCtrl.CityDel(id);
                RetModel ret = new RetModel
                {
                    Data = null,
                    ErrCode = "",
                    ErrInfo = "",
                    Success = true
                };
                return Ok(ret);
            }
            catch (Exception ex)
            {
                return Ok(new RetModel { Success = false, ErrCode = "Company011", ErrInfo = ex.Message, Data = null });
            }
        }
        [Route("GetCityList")]
        public IHttpActionResult PostGetCityList(int pId, string Token)
        {
            try
            {
                comm.CheckInfo(Token);
                comm.CheckAuth(comm.manager.id, "");
                var area = comm.companyCtrl.GetCityList(pId);
                RetModel ret = new RetModel
                {
                    Data = area,
                    ErrCode = "",
                    ErrInfo = "",
                    Success = true
                };
                return Ok(ret);
            }
            catch (Exception ex)
            {
                return Ok(new RetModel { Success = false, ErrCode = "Company012", ErrInfo = ex.Message, Data = null });
            }
        }
        /// <summary>
        /// 添加县
        /// </summary>
        /// <param name="District"></param>
        /// <param name="Token"></param>
        /// <returns></returns>
        [Route("DistrictAdd")]
        public IHttpActionResult PostDistrictAdd(AreaDistrictModel District, string Token)
        {
            try
            {
                comm.CheckInfo(Token);
                comm.CheckAuth(comm.manager.id, "District001");
                comm.companyCtrl.DistrictAdd(District);
                RetModel ret = new RetModel
                {
                    Data = null,
                    ErrCode = "",
                    ErrInfo = "",
                    Success = true
                };
                return Ok(ret);
            }
            catch (Exception ex)
            {
                return Ok(new RetModel { Success = false, ErrCode = "Company011", ErrInfo = ex.Message, Data = null });
            }
        }
        /// <summary>
        /// 修改县
        /// </summary>
        /// <param name="District"></param>
        /// <param name="Token"></param>
        /// <returns></returns>
        [Route("DistrictEdit")]
        public IHttpActionResult PostDistrictEdit(AreaDistrictModel District, string Token)
        {
            try
            {
                comm.CheckInfo(Token);
                comm.CheckAuth(comm.manager.id, "District002");
                comm.companyCtrl.DistrictEdit(District);
                RetModel ret = new RetModel
                {
                    Data = null,
                    ErrCode = "",
                    ErrInfo = "",
                    Success = true
                };
                return Ok(ret);
            }
            catch (Exception ex)
            {
                return Ok(new RetModel { Success = false, ErrCode = "Company011", ErrInfo = ex.Message, Data = null });
            }
        }
        /// <summary>
        /// 删除县
        /// </summary>
        /// <param name="District"></param>
        /// <param name="Token"></param>
        /// <returns></returns>
        [Route("DistrictDel")]
        public IHttpActionResult PostDistrictDel(int id, string Token)
        {
            try
            {
                comm.CheckInfo(Token);
                comm.CheckAuth(comm.manager.id, "District003");
                comm.companyCtrl.DistrictDel(id);
                RetModel ret = new RetModel
                {
                    Data = null,
                    ErrCode = "",
                    ErrInfo = "",
                    Success = true
                };
                return Ok(ret);
            }
            catch (Exception ex)
            {
                return Ok(new RetModel { Success = false, ErrCode = "Company011", ErrInfo = ex.Message, Data = null });
            }
        }
        [Route("GetDistrictList")]
        public IHttpActionResult PostGetDistrictList(int cId, string Token)
        {
            try
            {
                comm.CheckInfo(Token);
                comm.CheckAuth(comm.manager.id, "");
                var area = comm.companyCtrl.GetDistrictList(cId);
                RetModel ret = new RetModel
                {
                    Data = area,
                    ErrCode = "",
                    ErrInfo = "",
                    Success = true
                };
                return Ok(ret);
            }
            catch (Exception ex)
            {
                return Ok(new RetModel { Success = false, ErrCode = "Company013", ErrInfo = ex.Message, Data = null });
            }
        }
        #endregion
        #region 机关
        /// <summary>
        /// 添加省
        /// </summary>
        /// <param name="SBProvince"></param>
        /// <param name="Token"></param>
        /// <returns></returns>
        [Route("SBProvinceAdd")]
        public IHttpActionResult PostSBProvinceAdd(SBProvinceModel SBProvince, string Token)
        {
            try
            {
                comm.CheckInfo(Token);
                comm.CheckAuth(comm.manager.id, "SBProvince001");
                comm.companyCtrl.SBProvinceAdd(SBProvince);
                RetModel ret = new RetModel
                {
                    Data = null,
                    ErrCode = "",
                    ErrInfo = "",
                    Success = true
                };
                return Ok(ret);
            }
            catch (Exception ex)
            {
                return Ok(new RetModel { Success = false, ErrCode = "Company011", ErrInfo = ex.Message, Data = null });
            }
        }
        /// <summary>
        /// 修改省
        /// </summary>
        /// <param name="SBProvince"></param>
        /// <param name="Token"></param>
        /// <returns></returns>
        [Route("SBProvinceEdit")]
        public IHttpActionResult PostSBProvinceEdit(SBProvinceModel SBProvince, string Token)
        {
            try
            {
                comm.CheckInfo(Token);
                comm.CheckAuth(comm.manager.id, "SBProvince002");
                comm.companyCtrl.SBProvinceEdit(SBProvince);
                RetModel ret = new RetModel
                {
                    Data = null,
                    ErrCode = "",
                    ErrInfo = "",
                    Success = true
                };
                return Ok(ret);
            }
            catch (Exception ex)
            {
                return Ok(new RetModel { Success = false, ErrCode = "Company011", ErrInfo = ex.Message, Data = null });
            }
        }
        /// <summary>
        /// 删除省
        /// </summary>
        /// <param name="SBProvince"></param>
        /// <param name="Token"></param>
        /// <returns></returns>
        [Route("SBProvinceDel")]
        public IHttpActionResult PostSBProvinceDel(int id, string Token)
        {
            try
            {
                comm.CheckInfo(Token);
                comm.CheckAuth(comm.manager.id, "SBProvince003");
                comm.companyCtrl.SBProvinceDel(id);
                RetModel ret = new RetModel
                {
                    Data = null,
                    ErrCode = "",
                    ErrInfo = "",
                    Success = true
                };
                return Ok(ret);
            }
            catch (Exception ex)
            {
                return Ok(new RetModel { Success = false, ErrCode = "Company011", ErrInfo = ex.Message, Data = null });
            }
        }
        [Route("GetSBProvinceList")]
        public IHttpActionResult PostGetSBProvinceList(string Token)
        {
            try
            {
                comm.CheckInfo(Token);
                comm.CheckAuth(comm.manager.id, "");
                var area = comm.companyCtrl.GetSBProvinceList();
                RetModel ret = new RetModel
                {
                    Data = area,
                    ErrCode = "",
                    ErrInfo = "",
                    Success = true
                };
                return Ok(ret);
            }
            catch (Exception ex)
            {
                return Ok(new RetModel { Success = false, ErrCode = "Company011", ErrInfo = ex.Message, Data = null });
            }
        }
        /// <summary>
        /// 添加市
        /// </summary>
        /// <param name="SBProvince"></param>
        /// <param name="Token"></param>
        /// <returns></returns>
        [Route("SBCityAdd")]
        public IHttpActionResult PostSBCityAdd(SBCityModel SBCity, string Token)
        {
            try
            {
                comm.CheckInfo(Token);
                comm.CheckAuth(comm.manager.id, "SBCity001");
                comm.companyCtrl.SBCityAdd(SBCity);
                RetModel ret = new RetModel
                {
                    Data = null,
                    ErrCode = "",
                    ErrInfo = "",
                    Success = true
                };
                return Ok(ret);
            }
            catch (Exception ex)
            {
                return Ok(new RetModel { Success = false, ErrCode = "Company011", ErrInfo = ex.Message, Data = null });
            }
        }
        /// <summary>
        /// 修改市
        /// </summary>
        /// <param name="SBProvince"></param>
        /// <param name="Token"></param>
        /// <returns></returns>
        [Route("SBCityEdit")]
        public IHttpActionResult PostSBCityEdit(SBCityModel SBCity, string Token)
        {
            try
            {
                comm.CheckInfo(Token);
                comm.CheckAuth(comm.manager.id, "SBCity002");
                comm.companyCtrl.SBCityEdit(SBCity);
                RetModel ret = new RetModel
                {
                    Data = null,
                    ErrCode = "",
                    ErrInfo = "",
                    Success = true
                };
                return Ok(ret);
            }
            catch (Exception ex)
            {
                return Ok(new RetModel { Success = false, ErrCode = "Company011", ErrInfo = ex.Message, Data = null });
            }
        }
        /// <summary>
        /// 删除市
        /// </summary>
        /// <param name="SBProvince"></param>
        /// <param name="Token"></param>
        /// <returns></returns>
        [Route("SBCityDel")]
        public IHttpActionResult PostSBCityDel(int id, string Token)
        {
            try
            {
                comm.CheckInfo(Token);
                comm.CheckAuth(comm.manager.id, "SBCity003");
                comm.companyCtrl.SBCityDel(id);
                RetModel ret = new RetModel
                {
                    Data = null,
                    ErrCode = "",
                    ErrInfo = "",
                    Success = true
                };
                return Ok(ret);
            }
            catch (Exception ex)
            {
                return Ok(new RetModel { Success = false, ErrCode = "Company011", ErrInfo = ex.Message, Data = null });
            }
        }
        [Route("GetSBCityList")]
        public IHttpActionResult PostGetSBCityList(int pId, string Token)
        {
            try
            {
                comm.CheckInfo(Token);
                comm.CheckAuth(comm.manager.id, "");
                var area = comm.companyCtrl.GetSBCityList(pId);
                RetModel ret = new RetModel
                {
                    Data = area,
                    ErrCode = "",
                    ErrInfo = "",
                    Success = true
                };
                return Ok(ret);
            }
            catch (Exception ex)
            {
                return Ok(new RetModel { Success = false, ErrCode = "Company012", ErrInfo = ex.Message, Data = null });
            }
        }
        /// <summary>
        /// 添加县
        /// </summary>
        /// <param name="SBDistrict"></param>
        /// <param name="Token"></param>
        /// <returns></returns>
        [Route("SBDistrictAdd")]
        public IHttpActionResult PostSBDistrictAdd(SBDistrictModel SBDistrict, string Token)
        {
            try
            {
                comm.CheckInfo(Token);
                comm.CheckAuth(comm.manager.id, "SBDistrict001");
                comm.companyCtrl.SBDistrictAdd(SBDistrict);
                RetModel ret = new RetModel
                {
                    Data = null,
                    ErrCode = "",
                    ErrInfo = "",
                    Success = true
                };
                return Ok(ret);
            }
            catch (Exception ex)
            {
                return Ok(new RetModel { Success = false, ErrCode = "Company011", ErrInfo = ex.Message, Data = null });
            }
        }
        /// <summary>
        /// 修改县
        /// </summary>
        /// <param name="SBDistrict"></param>
        /// <param name="Token"></param>
        /// <returns></returns>
        [Route("SBDistrictEdit")]
        public IHttpActionResult PostSBDistrictEdit(SBDistrictModel SBDistrict, string Token)
        {
            try
            {
                comm.CheckInfo(Token);
                comm.CheckAuth(comm.manager.id, "SBDistrict002");
                comm.companyCtrl.SBDistrictEdit(SBDistrict);
                RetModel ret = new RetModel
                {
                    Data = null,
                    ErrCode = "",
                    ErrInfo = "",
                    Success = true
                };
                return Ok(ret);
            }
            catch (Exception ex)
            {
                return Ok(new RetModel { Success = false, ErrCode = "Company011", ErrInfo = ex.Message, Data = null });
            }
        }
        /// <summary>
        /// 删除县
        /// </summary>
        /// <param name="SBDistrict"></param>
        /// <param name="Token"></param>
        /// <returns></returns>
        [Route("SBDistrictDel")]
        public IHttpActionResult PostSBDistrictDel(int id, string Token)
        {
            try
            {
                comm.CheckInfo(Token);
                comm.CheckAuth(comm.manager.id, "SBDistrict003");
                comm.companyCtrl.SBDistrictDel(id);
                RetModel ret = new RetModel
                {
                    Data = null,
                    ErrCode = "",
                    ErrInfo = "",
                    Success = true
                };
                return Ok(ret);
            }
            catch (Exception ex)
            {
                return Ok(new RetModel { Success = false, ErrCode = "Company011", ErrInfo = ex.Message, Data = null });
            }
        }
        [Route("GetSBDistrictList")]
        public IHttpActionResult PostGetSBDistrictList(int cId, string Token)
        {
            try
            {
                comm.CheckInfo(Token);
                comm.CheckAuth(comm.manager.id, "");
                var area = comm.companyCtrl.GetSBDistrictList(cId);
                RetModel ret = new RetModel
                {
                    Data = area,
                    ErrCode = "",
                    ErrInfo = "",
                    Success = true
                };
                return Ok(ret);
            }
            catch (Exception ex)
            {
                return Ok(new RetModel { Success = false, ErrCode = "Company013", ErrInfo = ex.Message, Data = null });
            }
        }
        #endregion
        #region 行业

        /// <summary>
        /// 添加大类
        /// </summary>
        /// <returns></returns>
        [Route("TradeBigAdd")]
        public IHttpActionResult PostTradeBigAdd(TradeBigModel TradeBig, string Token)
        {
            try
            {
                comm.CheckInfo(Token);
                comm.CheckAuth(comm.manager.id, "TradeBig001");
                comm.companyCtrl.TradeBigAdd(TradeBig);
                RetModel ret = new RetModel
                {
                    Data = null,
                    ErrCode = "",
                    ErrInfo = "",
                    Success = true
                };
                return Ok(ret);
            }
            catch (Exception ex)
            {
                return Ok(new RetModel { Success = false, ErrCode = "Company011", ErrInfo = ex.Message, Data = null });
            }
        }
        /// <summary>
        /// 修改大类
        /// </summary>
        /// <returns></returns>
        [Route("TradeBigEdit")]
        public IHttpActionResult PostTradeBigEdit(TradeBigModel TradeBig, string Token)
        {
            try
            {
                comm.CheckInfo(Token);
                comm.CheckAuth(comm.manager.id, "TradeBig002");
                comm.companyCtrl.TradeBigEdit(TradeBig);
                RetModel ret = new RetModel
                {
                    Data = null,
                    ErrCode = "",
                    ErrInfo = "",
                    Success = true
                };
                return Ok(ret);
            }
            catch (Exception ex)
            {
                return Ok(new RetModel { Success = false, ErrCode = "Company011", ErrInfo = ex.Message, Data = null });
            }
        }
        /// <summary>
        /// 删除大类
        /// </summary>
        /// <returns></returns>
        [Route("TradeBigDel")]
        public IHttpActionResult PostTradeBigDel(int id, string Token)
        {
            try
            {
                comm.CheckInfo(Token);
                comm.CheckAuth(comm.manager.id, "TradeBig003");
                comm.companyCtrl.TradeBigDel(id);
                RetModel ret = new RetModel
                {
                    Data = null,
                    ErrCode = "",
                    ErrInfo = "",
                    Success = true
                };
                return Ok(ret);
            }
            catch (Exception ex)
            {
                return Ok(new RetModel { Success = false, ErrCode = "Company011", ErrInfo = ex.Message, Data = null });
            }
        }
        [Route("GetTradeBigList")]
        public IHttpActionResult PostGetTradeBigList(string Token)
        {
            try
            {
                comm.CheckInfo(Token);
                comm.CheckAuth(comm.manager.id, "");
                var area = comm.companyCtrl.GetTradeBigList();
                RetModel ret = new RetModel
                {
                    Data = area,
                    ErrCode = "",
                    ErrInfo = "",
                    Success = true
                };
                return Ok(ret);
            }
            catch (Exception ex)
            {
                return Ok(new RetModel { Success = false, ErrCode = "Company011", ErrInfo = ex.Message, Data = null });
            }
        }
        /// <summary>
        /// 添加中类
        /// </summary>
        /// <param name="TradeMid"></param>
        /// <param name="Token"></param>
        /// <returns></returns>
        [Route("TradeMidAdd")]
        public IHttpActionResult PostTradeMidAdd(TradeMidModel TradeMid, string Token)
        {
            try
            {
                comm.CheckInfo(Token);
                comm.CheckAuth(comm.manager.id, "TradeMid001");
                comm.companyCtrl.TradeMidAdd(TradeMid);
                RetModel ret = new RetModel
                {
                    Data = null,
                    ErrCode = "",
                    ErrInfo = "",
                    Success = true
                };
                return Ok(ret);
            }
            catch (Exception ex)
            {
                return Ok(new RetModel { Success = false, ErrCode = "Company011", ErrInfo = ex.Message, Data = null });
            }
        }
        /// <summary>
        /// 修改中类
        /// </summary>
        /// <param name="TradeMid"></param>
        /// <param name="Token"></param>
        /// <returns></returns>
        [Route("TradeMidEdit")]
        public IHttpActionResult PostTradeMidEdit(TradeMidModel TradeMid, string Token)
        {
            try
            {
                comm.CheckInfo(Token);
                comm.CheckAuth(comm.manager.id, "TradeMid002");
                comm.companyCtrl.TradeMidEdit(TradeMid);
                RetModel ret = new RetModel
                {
                    Data = null,
                    ErrCode = "",
                    ErrInfo = "",
                    Success = true
                };
                return Ok(ret);
            }
            catch (Exception ex)
            {
                return Ok(new RetModel { Success = false, ErrCode = "Company011", ErrInfo = ex.Message, Data = null });
            }
        }
        /// <summary>
        /// 删除中类
        /// </summary>
        /// <param name="TradeMid"></param>
        /// <param name="Token"></param>
        /// <returns></returns>
        [Route("TradeMidDel")]
        public IHttpActionResult PostTradeMidDel(int id, string Token)
        {
            try
            {
                comm.CheckInfo(Token);
                comm.CheckAuth(comm.manager.id, "TradeMid003");
                comm.companyCtrl.TradeMidDel(id);
                RetModel ret = new RetModel
                {
                    Data = null,
                    ErrCode = "",
                    ErrInfo = "",
                    Success = true
                };
                return Ok(ret);
            }
            catch (Exception ex)
            {
                return Ok(new RetModel { Success = false, ErrCode = "Company011", ErrInfo = ex.Message, Data = null });
            }
        }
        [Route("GetTradeMidList")]
        public IHttpActionResult PostGetTradeMidList(int bId, string Token)
        {
            try
            {
                comm.CheckInfo(Token);
                comm.CheckAuth(comm.manager.id, "");
                var area = comm.companyCtrl.GetTradeMidList(bId);
                RetModel ret = new RetModel
                {
                    Data = area,
                    ErrCode = "",
                    ErrInfo = "",
                    Success = true
                };
                return Ok(ret);
            }
            catch (Exception ex)
            {
                return Ok(new RetModel { Success = false, ErrCode = "Company012", ErrInfo = ex.Message, Data = null });
            }
        }
        /// <summary>
        /// 添加小类
        /// </summary>
        /// <param name="TradeSmall"></param>
        /// <param name="Token"></param>
        /// <returns></returns>
        [Route("TradeSmallAdd")]
        public IHttpActionResult PostTradeSmallAdd(TradeSmallModel TradeSmall, string Token)
        {
            try
            {
                comm.CheckInfo(Token);
                comm.CheckAuth(comm.manager.id, "TradeSmall001");
                comm.companyCtrl.TradeSmallAdd(TradeSmall);
                RetModel ret = new RetModel
                {
                    Data = null,
                    ErrCode = "",
                    ErrInfo = "",
                    Success = true
                };
                return Ok(ret);
            }
            catch (Exception ex)
            {
                return Ok(new RetModel { Success = false, ErrCode = "Company011", ErrInfo = ex.Message, Data = null });
            }
        }
        /// <summary>
        /// 修改小类
        /// </summary>
        /// <param name="TradeSmall"></param>
        /// <param name="Token"></param>
        /// <returns></returns>
        [Route("TradeSmallEdit")]
        public IHttpActionResult PostTradeSmallEdit(TradeSmallModel TradeSmall, string Token)
        {
            try
            {
                comm.CheckInfo(Token);
                comm.CheckAuth(comm.manager.id, "TradeSmall002");
                comm.companyCtrl.TradeSmallEdit(TradeSmall);
                RetModel ret = new RetModel
                {
                    Data = null,
                    ErrCode = "",
                    ErrInfo = "",
                    Success = true
                };
                return Ok(ret);
            }
            catch (Exception ex)
            {
                return Ok(new RetModel { Success = false, ErrCode = "Company011", ErrInfo = ex.Message, Data = null });
            }
        }
        /// <summary>
        /// 删除小类
        /// </summary>
        /// <param name="TradeSmall"></param>
        /// <param name="Token"></param>
        /// <returns></returns>
        [Route("TradeSmallDel")]
        public IHttpActionResult PostTradeSmallDel(int id, string Token)
        {
            try
            {
                comm.CheckInfo(Token);
                comm.CheckAuth(comm.manager.id, "TradeSmall003");
                comm.companyCtrl.TradeSmallDel(id);
                RetModel ret = new RetModel
                {
                    Data = null,
                    ErrCode = "",
                    ErrInfo = "",
                    Success = true
                };
                return Ok(ret);
            }
            catch (Exception ex)
            {
                return Ok(new RetModel { Success = false, ErrCode = "Company011", ErrInfo = ex.Message, Data = null });
            }
        }
        [Route("GetTradeSmallList")]
        public IHttpActionResult PostGetTradeSmallList(int mId, string Token)
        {
            try
            {
                comm.CheckInfo(Token);
                comm.CheckAuth(comm.manager.id, "");
                var area = comm.companyCtrl.GetTradeSmallList(mId);
                RetModel ret = new RetModel
                {
                    Data = area,
                    ErrCode = "",
                    ErrInfo = "",
                    Success = true
                };
                return Ok(ret);
            }
            catch (Exception ex)
            {
                return Ok(new RetModel { Success = false, ErrCode = "Company013", ErrInfo = ex.Message, Data = null });
            }
        }
        #endregion
    }
}